package com.restfinder.user.dao;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.restfinder.common.dao.StandardDAO;
import com.restfinder.user.model.Role;

@Repository
public class DatabaseRoleRepository extends StandardDAO<Role> implements RoleRepository {

	private static final long serialVersionUID = 1L;

	@Override
	public Class getEntityClass() {
		return Role.class;
	}
	
	public Role getByCode(String code) {
		Query query = this.sessionFactory.getCurrentSession().createQuery("from Role where code =:code").setString("code", code);
		Role role = (Role) query.uniqueResult();
		return role;		
	}


}
